package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltHealthScoreReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltHealthScoreRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltHealthScore;
import java.util.Objects;

/**
 * BeltHealthScore DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-10-24
 */
public class BeltHealthScoreAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltHealthScore dto2entity(BeltHealthScoreReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltHealthScore entity = new BeltHealthScore();
    entity.setBeltId(dto.getBeltId());
    entity.setTaskId(dto.getTaskId());
    entity.setRouteId(dto.getRouteId());
    entity.setDeductionItem(dto.getDeductionItem());
    entity.setDeductionScore(dto.getDeductionScore());
    entity.setHealthType(dto.getHealthType());
    entity.setScoreTime(dto.getScoreTime());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltHealthScore dto2entity(BeltHealthScoreReqDTO dto, BeltHealthScore entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getBeltId())) {
      entity.setBeltId(dto.getBeltId());
    }
    if(Objects.nonNull(dto.getTaskId())) {
      entity.setTaskId(dto.getTaskId());
    }
    if(Objects.nonNull(dto.getRouteId())) {
      entity.setRouteId(dto.getRouteId());
    }
    if(Objects.nonNull(dto.getDeductionItem())) {
      entity.setDeductionItem(dto.getDeductionItem());
    }
    if(Objects.nonNull(dto.getDeductionScore())) {
      entity.setDeductionScore(dto.getDeductionScore());
    }
    if(Objects.nonNull(dto.getHealthType())) {
      entity.setHealthType(dto.getHealthType());
    }
    if(Objects.nonNull(dto.getScoreTime())) {
      entity.setScoreTime(dto.getScoreTime());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltHealthScoreRespVO entity2dto(BeltHealthScore entity) {
    if (entity == null) {
      return null;
    }
    BeltHealthScoreRespVO dto = new BeltHealthScoreRespVO();
    dto.setId(entity.getId());
    dto.setBeltId(entity.getBeltId());
    dto.setTaskId(entity.getTaskId());
    dto.setRouteId(entity.getRouteId());
    dto.setDeductionItem(entity.getDeductionItem());
    dto.setDeductionScore(entity.getDeductionScore());
    dto.setHealthType(entity.getHealthType());
    dto.setScoreTime(entity.getScoreTime());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyTime(entity.getModifyTime());
    dto.setCreateUser(entity.getCreateUser());
    dto.setModifyUser(entity.getModifyUser());
    return dto;
  }

}
